<extend name="Public/base" />

<block name="style" >
    <style>
        .user_table{
            border: 1px solid #ddd;
            width: 180px;
        }
        .user_table tr{
            border: 1px solid #dddddd;
            height: 30px;
        }
        .user_table td{
            border: 1px solid #dddddd;
            width: 90px;
            text-align: center;
        }
    </style>
</block>

<block name="body">
    <!-- 弹窗插件 -->
    <include file="Public:artdialog" />
    <!-- 表单验证插件 -->
    <include file="Public:validform" />

    <form action="{:U('addmenu')}" method="post" role="form" class="form-horizontal row-border vform" > 
        <input type="hidden" name="menuid" value="{$entity.menuid}" id="menuid"> 
        <div class="row">
            <div class="col-md-12">
                <div class="block-web">
                    <div class="header">
                        <h3 class="content-header">添加/修改</h3>
                    </div>
                    <div class="porlets-content"> 
                    
                      <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>上级</label>
                            <div class="col-sm-3">
                           <select name="pid" class="normal_select" id="pid" field="{$entity.pid}">
								<option value="0">作为一级菜单</option> 
                                   <volist name="parentmenu" id="mp"> 
									<option value="{$mp.menuid}">{$mp.mname}</option>
								   </volist>
							 </select>
                            </div>
                        </div>  
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>菜单名称</label>
                            <div class="col-sm-3">
                                <input type="text" value="{$entity.mname}" name="mname"  class="form-control " datatype="*" nullmsg="请输入标题" />
                                <div class="Validform_checktip"></div>
                            </div>
                        </div> 
                        
                          <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>类型</label>
                            <div class="col-sm-3">
                            <select name="menutype" id="mtype" field="{$entity.menutype}">
									<option value="view" selected="">超链接</option>
									<option value="click">点击事件</option>
							</select> 
							</div>
                        </div>  
                         <div class="form-group">
                            <label class="col-sm-3 control-label">链接地址</label>
                            <php>
                             $wxpath= C('WXConfigPathUrl');
                            </php>
                             <input type="text" class="input" name="url" value="{$entity.url}" autocomplete="off"  id="url_reid" field="{$wxpath}">
                              <select id="backrid"> 
                                        <option value="">外部链接</option>
                                        <volist name="wxmenu" id="o">
                                           <option value="{$o.url}">{$o.name}</option>
                                        </volist>
	                                 </select>
                                 <p class="help-block pull-right">不为空，自定义访问当前地址.</p>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-sm-3 control-label">点击事件key</label>
                            <div class="col-sm-3">
                                <input type="text"  name="keyword" value="{$entity.keyword}"  placeholder="请输入关键词" class="form-control" />
                                <div class="Validform_checktip"></div>
                            </div>
                        </div>  
                       
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><font class="red">*</font>排序</label>
                            <div class="col-sm-3">
                               <input type="text" class="input" name="listorder" value="{$entity.listorder}" placeholder="请输入排序" class="form-control" datatype="*" nullmsg="请输入排序" />
                                <div class="Validform_checktip"></div>
                            </div>
                        </div>  
                        
                        <div class="form-group" >
                            <label class="col-sm-3 control-label"><font class="red">*</font>是否有效</label>
                            <div class="col-sm-6">
                                <label class="radio-inline">
                                    <input type="radio"  name="status" value="1"  {$entity['status']==1?'checked':''}>
                                    <span class="custom-radio"></span> 有效
                                </label>
                                <label class="radio-inline">
                                    <input type="radio"  name="status" value="0"  {$entity['status']==0?'checked':''}>
                                    <span class="custom-radio"></span> 无效
                                </label>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-sm-3 control-label"></label>
                            <button class="btn btn-primary btn-success bt_submit" type="submit" id="submit">提交</button>
                        </div>
                    </div><!--/porlets-content-->
                </div><!--/block-web-->
            </div> 
        </div> 
    </form> 

</block>
<block name="script">
 <script type="text/javascript">
   $(function(){
	   $("#backrid").bind("change",function(){
		    var _url=$(this).val();
		    $("#url_reid").val(_url);
		});
	   
	   var _id=$("#menuid").val();
	   if(_id){
		   setTimeout(function(){init();},300)
	   }
   })
   
   var init=function(){

   
       $("#pid").val($("#pid").attr("field")); 
	   $("#mtype").val($("#mtype").attr("field"));  
	   
	   //处理url设置
	    var wxconfigpath=$("#url_reid").attr("field");
	    var thedomain= location.protocol+"//"+location.host + wxconfigpath;
	    var url=$("#url_reid").val();	    	
		url= url.replace(thedomain,"");
		if(url.indexOf("http://")!=-1)url="";
	    $("#backrid").val(url);
   } 
  </script>

</block>
